package com.foreknow.demo9;
//1，有十万个数据，找到第一个重复的数据

import java.util.*;

public class Test1 {
    public static void main(String[] args) {
        List<Integer> integers = new ArrayList<>();
        Random random = new Random();
        for (int i = 0;i < 100000;i++){
            integers.add(random.nextInt(100000));
        }
        Set<Integer> set = new TreeSet<>();
        for (int i = 0;i<integers.size();i++) {
            boolean isRight = set.add(integers.get(i));
            if (isRight==false){
                System.out.println(integers.get(i));
                break;
            }
        }
    }
}
